<template>
  <el-select v-if="this.options" @change="this.handleChange" v-model="selectedValue" placeholder="请选择">
    <el-option
      v-for="item in options"
      :key="item[optionValue]"
      :label="item[optionLabel]"
      :value="item[optionValue]">
    </el-option>
  </el-select>
</template>

<script>
export default {
  props: {
    value: {
      required: true
    },
    options: {
      type: Array,
      required: false
    },
    optionValue: {
      type: String,
      required: false,
      default: 'value'
    },
    optionLabel: {
      type: String,
      required: false,
      default: 'label'
    }
  },
  data () {
    return {
      selectedValue: this.value
    }
  },
  methods: {
    handleChange () {
      this.$emit('input', this.selectedValue)
    }
  }
}
</script>
